package com.Managers;


import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Calendar;
import android.os.Environment;


public class LogManagerClass {

    public static void writeLog(String text) {

        String path = Environment.getExternalStorageDirectory()
                    + DirManagerClass.ThumbsPath + "log.txt";
        String log = Calendar.getInstance().getTime().toString()
                    + " - " + text;
        File logFile = new File(path);
        if (!logFile.exists()) {
            try {
                logFile.createNewFile();
            }
            catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        try {
            // BufferedWriter for performance, true to set append to file flag
            BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
            buf.append(log);
            buf.newLine();
            buf.close();
        }
        catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
